package com.ssm.service.imp;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.CustomerMapper;
import com.ssm.pojo.Customer;
import com.ssm.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImp implements CustomerService{

    @Autowired
    private CustomerMapper customerMapper;

    public void insert(Customer customer) {
        customerMapper.insert(customer);
    }

    public void update(Customer customer) {
        customerMapper.update(customer);
    }

    public void deleteByCustomerNO(String customerNO) {
        customerMapper.deleteByCustomerNO(customerNO);

    }

    public List<Customer> seleteCustomersPage(String customerNO, Integer pageNum, Integer pageSize) {
        if(pageNum!=null && pageSize!=null){
            PageHelper.startPage(pageNum, pageSize);
        }
        return customerMapper.selectCustomersPage(customerNO);
    }

    public Integer selectSize(String customerNO) {
        Integer size = customerMapper.countSize(customerNO);
        return size;
    }

    public Customer selectCustomerByNO(String NO) {
        Customer customer=customerMapper.selectByCustomerNO(NO);
        return customer;
    }

    public Customer selectByNameAndPassword(String userName, String password) {
        Customer customer = customerMapper.selectByNameAndPassword(userName,password);
        return customer;
    }
}
